package com.dahua.simplefactory.version1;

import java.util.Scanner;

/**
 * 实现一个简单的加减乘除计算器方法
 * @author sunhongguang
 * @create 2022-01-09-10:56
 */
public class Calculate {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输出数字A： ");
        double numberA = scanner.nextDouble();

        System.out.println("请选择运算符号： ");
        String strOperate = scanner.next();

        System.out.println("请输出数字B： ");
        double numberB = scanner.nextDouble();

        Double result = null;
        if(strOperate.equals("+")){
            result = numberA+numberB;
        }
        if(strOperate.equals("-")){
            result = numberA+numberB;
        }
        if(strOperate.equals("*")){
            result = numberA*numberB;
        }
        if(strOperate.equals("/")){
            result = numberA/numberB;
        }
        System.out.println("结果是："+result);
    }

}
